package com.zeng.jiudian.servlet.newType;

import com.alibaba.fastjson.JSONObject;
import com.zeng.jiudian.bean.NewTypeModel;
import com.zeng.jiudian.service.NewTypeService;
import com.zeng.jiudian.service.impl.NewTypeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author JJ_yo
 * @Date 2020/8/13 - 16:31
 */
@WebServlet("/back/newType/findById")
public class NewTypeFindByIdServlet extends HttpServlet
{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        String idString = req.getParameter("id");
        int id = (idString == null || "".equals(idString) ? 0 : Integer.parseInt(idString));

        NewTypeService service = new NewTypeServiceImpl();
        NewTypeModel model = service.findById(id);

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("model", model);
        resp.getWriter().println(jsonObject);
    }
}
